#include <bits/stdc++.h>
using namespace std;
int T;
int n;
int ans;
int A[200005],c[200005];
int  cnt[1000001];
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        ans=0;
        memset(A,0,sizeof(A));
        memset(c,0,sizeof(c));
        memset(cnt,0,sizeof(cnt));
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>A[i];
            cnt[A[i]]++;
        }
        for(int i=1;i<=100005;i++){
            if(cnt[i]>=2)
                ans+=i;
        }
        cout<<ans<<endl;
    }
    return 0;
}
